"""
类装饰器：
    在不修改函数源代码的前提下，增加新的功能
"""


class AAA():
    def __init__(self, func):
        # print("我是AAA.init()")
        self.__func = func

    # 报错：TypeError: 'AAA' object is not callable
    # 要实现call方法
    def __call__(self, *args, **kwargs):
        print("在这里可以实现新增任意功能")
        self.addFunc()
        self.__func()

    def addFunc(self):
        print("用户权限验证")
        print("日志系统处理")


@AAA
# TypeError: __init__() takes 1 positional argument but 2 were given
# @AAA等价于test1 = AAA(test1)
def test1():
    print("我是功能1")


test1()
